/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dao.jpa;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Thuan
 */
public class JPAUtil {
    
    private static JPAUtil instance;
    private final EntityManagerFactory emf;
    
    private JPAUtil(){
        
        emf = Persistence.createEntityManagerFactory("" + "DotsAndBoxesPU");
    }
    
    public static JPAUtil getInstance(){
        
        if (instance == null){
            instance = new JPAUtil();
        }
        return instance;
    }
    
    public EntityManager createEM(){
        return emf.createEntityManager();
    }
    
}
